﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace Smart.Model
{
     [ServiceContract]
    public interface ICaloriesCalculator
    {
         [OperationContract]
         List<MealCategory> GetAllCategories();

         [OperationContract]
         List<MealTiny> GetAllMeals();

         [OperationContract]
         List<MealTiny> GetAllMealsFromCategory(int catId);

         [OperationContract]
         CalculatedResult CalculateCaloriesForMeal(int mealId, int quantity);

         [OperationContract]
         CalculatedResult CalculateCalories(List<KeyValuePair<int,int>> list);

         [OperationContract]
         void RecordMeal(int userId, int mealId, int quantity);
    }

     #region Composite Types
    [DataContract]
     public class MealTiny 
     {
         public MealTiny(int id, string name, string details)
         {
             Id = id;
             Name = name;
             Details = details;
         }
         public override bool Equals(System.Object obj1)
         {
             if (obj1 == null)
                 return false;

             MealTiny obj = obj1 as MealTiny;
             if ((System.Object)obj == null)
                 return false;

             return ((this.Id == obj.Id) && (this.Name == obj.Name) && (this.Details == obj.Details));
            // return true;
         }
        
        [DataMember]
         public int Id { get; set; }
        [DataMember]
         public string Name { get; set; }
        [DataMember]
         public string Details { get; set; }

     }
    [DataContract]
     public class CalculatedResult
     {
         public CalculatedResult(double cals, double prots, double carbs, double fats)
         {
             TotalCals = cals;
             TotalCarbs = carbs;
             TotalFats = fats;
             TotalProts = prots;

         }
        [DataMember]
         public double TotalCals { get; set; }
        [DataMember]
         public double TotalProts { get; set; }
        [DataMember]
         public double TotalCarbs { get; set; }
        [DataMember]
         public double TotalFats { get; set; }
     }
    #endregion
}
